package com.yipei.business.controller;

import com.yipei.business.domain.MlStopTradeSymbol;
import com.yipei.business.service.IMlStopTradeSymbolService;
import com.yipei.common.annotation.Log;
import com.yipei.common.core.controller.BaseController;
import com.yipei.common.core.domain.AjaxResult;
import com.yipei.common.core.page.TableDataInfo;
import com.yipei.common.enums.BusinessType;
import com.yipei.common.utils.poi.ExcelUtil;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.web.bind.annotation.*;

import javax.servlet.http.HttpServletResponse;
import java.util.List;

/**
 * 禁止交易Controller
 *
 * @author yipei
 * @date 2024-12-23
 */
@RestController
@RequestMapping("/business/symbol")
@Api(tags = "禁止交易", description = "禁止交易")
public class MlStopTradeSymbolController extends BaseController {
    @Autowired
    private IMlStopTradeSymbolService mlStopTradeSymbolService;

    /**
     * 查询禁止交易列表
     */
    //@PreAuthorize("@ss.hasPermi('business:symbol:list')")
    @ApiOperation("禁止交易获取数据")
    @GetMapping("/list")
    public TableDataInfo list(MlStopTradeSymbol mlStopTradeSymbol) {
        startPage();
        List<MlStopTradeSymbol> list = mlStopTradeSymbolService.selectMlStopTradeSymbolList(mlStopTradeSymbol);
        return getDataTable(list);
    }

    /**
     * 导出禁止交易列表
     */
    //@PreAuthorize("@ss.hasPermi('business:symbol:export')")
    @ApiOperation("禁止交易导出数据")
    @Log(title = "禁止交易", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, MlStopTradeSymbol mlStopTradeSymbol) {
        List<MlStopTradeSymbol> list = mlStopTradeSymbolService.selectMlStopTradeSymbolList(mlStopTradeSymbol);
        ExcelUtil<MlStopTradeSymbol> util = new ExcelUtil<MlStopTradeSymbol>(MlStopTradeSymbol.class);
        util.exportExcel(response, list, "禁止交易数据");
    }

    /**
     * 获取禁止交易详细信息
     */
    //@PreAuthorize("@ss.hasPermi('business:symbol:query')")
    @ApiOperation("禁止交易通过ID获取数据")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id) {
        return success(mlStopTradeSymbolService.selectMlStopTradeSymbolById(id));
    }

    /**
     * 新增禁止交易
     */
    //@PreAuthorize("@ss.hasPermi('business:symbol:add')")
    @ApiOperation("禁止交易新增数据")
    @Log(title = "禁止交易", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody MlStopTradeSymbol mlStopTradeSymbol) {
        return toAjax(mlStopTradeSymbolService.insertMlStopTradeSymbol(mlStopTradeSymbol));
    }

    /**
     * 修改禁止交易
     */
    //@PreAuthorize("@ss.hasPermi('business:symbol:edit')")
    @ApiOperation("禁止交易修改数据")
    @Log(title = "禁止交易", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody MlStopTradeSymbol mlStopTradeSymbol) {
        return toAjax(mlStopTradeSymbolService.updateMlStopTradeSymbol(mlStopTradeSymbol));
    }

    /**
     * 删除禁止交易
     */
    //@PreAuthorize("@ss.hasPermi('business:symbol:remove')")
    @ApiOperation("禁止交易删除数据")
    @Log(title = "禁止交易", businessType = BusinessType.DELETE)
    @DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids) {
        return toAjax(mlStopTradeSymbolService.deleteMlStopTradeSymbolByIds(ids));
    }
}
